*************************************************
*			04_windiq							*
*												*
*	Clean generation data from windIQ data		*
*												*
*	Raw: 	windiq_report (2020) 
*				--now CleanPower IQ				*
*	Output: windiq_repower.dta					*
*												*
*************************************************




***
* Import Wind IQ data
***  

import delimited "${wind}/data_raw/windiq/windiq_report_2020.csv",  clear

* Prepare variables 
keep eiaplantcode repowertype mw_total_capacity
ren eiaplantcode facilityid 

* Repowering
replace repowertype = "Never Repowered" if repowertype==""
bys facilityid: gegen repower_flag = max(!regexm(repower,"Never"))

***
* Clean up and Save
***

* Facility Level Data (max repowering)
drop if facilityid==.
keep facilityid repower_flag 
gduplicates drop
isid facilityid

* Label
label var repower_flag		"Whether repowered (from AWEA WindIQ)"

	
* Save
save "${wind}/temp/windiq_repower.dta"  , replace


